package com.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.CustomBean;
import com.project.bean.SupplierBean;
import com.project.service.ICustomService;
import com.project.service.IStockShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("custom")
@Api(tags = "客户")
public class CustomController {
    @Autowired
    private ICustomService customService;

    @ApiOperation(value = "分页动态查询客户信息")
    @GetMapping("cutByItem")
    public IPage<CustomBean> cutByItem(Integer pageNO, String name, String scope) {
        return customService.cutByItem(pageNO, name, scope);
    }

    @ApiOperation(value = "按id查询客户信息")
    @GetMapping("findById")
    public CustomBean findById(Integer id) {
        return customService.findById(id);
    }

    @ApiOperation(value = "按id修改客户信息")
    @PutMapping("update")
    public String update(Integer id, String director, String phone, String scope) {
        customService.update(id, director, phone, scope);
        return "ok";
    }

    @ApiOperation(value = "查看客户是否存在")
    @GetMapping("findByName")
    public CustomBean findByName(String name) {
        return customService.findByName(name);
    }

    @ApiOperation(value = "添加客户")
    @PostMapping("add")
    public String add(CustomBean customBean) {
        customService.add(customBean);
        return "ok";
    }

    @ApiOperation(value = "查看所有客户")
    @GetMapping("findAll")
    public List<CustomBean> findAll() {
        return customService.findAll();
    }
}
